package <%= domainPackageName %>;

import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.hibernate.annotations.GenericGenerator;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;

/**
* <%= camelCaseName(tableName,true) %> <%=tableComment %> 实体
*
* @author 代码生成器@zhangQ
* @date <%= formatTime() %>
*/
@Entity
@Table(name = "<%= tableName %>")
public class <%= camelCaseName(tableName,true) %> implements Serializable {

    private static final long serialVersionUID = 1L;
<% table.columns.forEach(function(item){ %>
    /**
    * <%= item.remark %>
    */
    <%_ if(item.primaryKey) { -%>
    @Id
    @GeneratedValue(generator = "IdWork")
    @GenericGenerator(name = "IdWork", strategy = "com.xliance.utils.IdWork")
    <%_ } -%>
    private <%= item.type %> <%= camelCaseName(item.name) %>;
<% }); %>
<% table.columns.forEach(function(item){ -%>
    public <%= item.type %> get<%= camelCaseName(item.name,true) %>() {
        return <%= camelCaseName(item.name) %>;
    }

    public void set<%= camelCaseName(item.name,true) %>(<%= item.type %> <%= camelCaseName(item.name) %>) {
        this.<%= camelCaseName(item.name) %> = <%= camelCaseName(item.name) %>;
    }

<% }); -%>

    /**
    * 判断是否相等
    */
    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null || getClass() != obj.getClass()) {
            return false;
        }

        <%= camelCaseName(tableName,true) %> <%= camelCaseName(tableName) %> = (<%= camelCaseName(tableName,true) %>) obj;
        return new EqualsBuilder()
<% table.columns.forEach(function(item){ -%>
            .append(<%= camelCaseName(item.name) %>, <%= camelCaseName(tableName) %>.<%= camelCaseName(item.name) %>)
<% }); -%>
            .isEquals();
    }

    @Override
    public int hashCode() {
        return new HashCodeBuilder()
<% table.columns.forEach(function(item){ -%>
                .append(<%= camelCaseName(item.name) %>)
<% }); -%>
                .toHashCode();
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this)
<% table.columns.forEach(function(item){ -%>
                .append("<%= camelCaseName(item.name) %>", <%= camelCaseName(item.name) %>)
<% }); -%>
                .toString();
    }

}